/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package teamgandalf;

import java.io.*;
import java.util.*;

/**
 *
 * @author Bryce
 */
public class ProductReader {
    private Scanner source;
    private ProductSpec product;
    
    ProductReader(String productFile) throws IOException{
        source = new Scanner(new FileReader(productFile));
        source.useDelimiter("\\s+");
    }

    boolean hasMoreProducts(){
        if (source.hasNext()) {
            return true;
        } else {
            return false;
        }
    }
    
    ProductSpec getNextProduct(){
        product = new ProductSpec(source.nextInt(), source.next(), source.nextDouble());
        return product;
    }

    
    // for test purposes
    public static void main(String[] args) throws IOException {
        ProductReader test = new ProductReader("products.txt");
        ProductSpec product = test.getNextProduct();
        System.out.println(product.getUPC());
        System.out.println(product.getDescription());
        System.out.println(product.getPrice());
        ProductSpec product2 = test.getNextProduct();
        System.out.println(product2.getUPC());
        System.out.println(product2.getDescription());
        System.out.println(product2.getPrice());
        
    }
}
